import 'package:dio/dio.dart';

import '../../main.dart';
import '../base/dio_service.dart';
import '../interceptor/ErrorInterceptor.dart';
import '../interceptor/ResponseInterceptor.dart';

const String comServiceKey = "COMService";
const String apiPrefix = "";

class COMService extends DioService {
  @override
  String serviceKey() {
    return comServiceKey;
  }

  @override
  void initDio() {
    super.initDio();
    dio.options.baseUrl = HOST + apiPrefix;
    dio.options.contentType = "application/json";
    // dio.options.contentType = "application/x-www-form-urlencoded";
    // dio.options.contentType = "multipart/form-data";
    dio.options.connectTimeout = const Duration(seconds: 15);
    // 拦截器
    // 日志拦截器
    dio.interceptors.add(LogInterceptor(request: true, requestBody: true, responseBody: true));
    dio.interceptors.add(ErrorInterceptor());
    dio.interceptors.add(ResponseInterceptor());
    // token拦截器
    // dio.interceptors.add(TokenInterceptor());
  }
}